package org.streets.eis.ext.analysis.internal.buildlogic;

import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import org.streets.database.datadict.TableDefinition;
import org.streets.eis.ext.analysis.components.ColumnWrapper;
import org.streets.eis.ext.analysis.entities.DisplayField;
import org.streets.eis.ext.analysis.entities.OrderField;
import org.streets.eis.ext.analysis.entities.QueryStruct;
import org.streets.eis.ext.analysis.entities.WhereField;

public interface QueryBuilderLogic extends Serializable {

	public void appendTable(QueryStruct query, String table,String alias,Boolean allShow);	
	public void removeTable(QueryStruct query, String table);	
	
	public void appendDisplayField(QueryStruct query,DisplayField field);
	public void removeDisplayField(QueryStruct query,DisplayField field);	
	public void appendDisplayField(QueryStruct query,String field);
	public void removeDisplayField(QueryStruct query,String field);	

	public void displayFieldSelectChanged(QueryStruct query,ColumnWrapper w);
	public void orderFieldSelectionChanged(QueryStruct query,ColumnWrapper w);
	
	public void appendOrderField(QueryStruct query,String fieldName,String orderType);
	public void appendOrderField(QueryStruct query,OrderField d);
	public void removeOrderField(QueryStruct query,OrderField w);
	
	public void appendWhereField(QueryStruct query,String condition);
	public void appendWhereField(QueryStruct query,ColumnWrapper w);
	public void removeWhereField(QueryStruct query,WhereField w);
	 
	public List<QueryStruct> findQueries();
	public void delete(QueryStruct query);
    public void save(QueryStruct query);

    public List<ColumnWrapper> loadFields(TableDefinition table);

	public String findParentTableCode(String tableCode,String fieldCode);
	
	public java.io.File exportExcel(QueryStruct selectedQuery) throws SQLException,IOException;

	
	public String buildFieldExpr(List<WhereField> whereFields, String condition);
	
	public boolean isValid(QueryStruct query, StringBuffer hint);
	
}